﻿using System;
using System.Drawing;
using System.Windows.Forms;
using pub.CmdUI.Cmd;
using pub.NET20Fix;

namespace pub.CmdUI.UI.Control
{
    public class MenuUI : IControlUI
    {
        private Action _triggerCallback;
        private MenuItem _menuItem;

        public MenuUI(MenuItem menuItem)
        {
            this._menuItem = menuItem;
            menuItem.Click += menuItem_Click;
        }

        private void menuItem_Click(object sender, EventArgs e)
        {
            if (_triggerCallback != null)
            {
                _triggerCallback();
            }
        }

        public Action TriggerCallback
        {
            set { _triggerCallback = value; }
        }

        public Bitmap Icon
        {
            set
            {
                //
            }
        }

        public string Label
        {
            set
            {
                // 
            }
        }

        public string Tooltip
        {
            set
            {
                //
            }
        }

        public void Update(ICmd cmd)
        {
            _menuItem.Enabled = cmd.State.Enabled;
            _menuItem.Checked = cmd.State.Checked ?? false;
//            if (_menuItem.Text == "&Progress")
//            {
//                Debug.Print("@@@@@@@@ Setting Progress Checked to " + _menuItem.Checked + " @" + DateTime.Now);
//            }
        }
    }
}